// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Data/MissionStruct.h"
#include "TimerWidget.generated.h"

UCLASS()
class MISCELLANEOUSPROJECT_API UTimerWidget : public UUserWidget
{
	GENERATED_BODY()
public:
	virtual void NativeConstruct() override;
	virtual void NativeDestruct() override;
	
public:
	void ConstructWidget(const FTimerInfo& TargetInfo, float WarningTime);
	UFUNCTION(BlueprintCallable, Category = MissionComponent)
	void RequestDestruct();
	UFUNCTION(BlueprintCallable, Category = MissionComponent)
	FText SecondsToText(float Seconds);
	void TimeCounter();
private:
	void DelayLater();
public:
	UPROPERTY(meta = (BindWidget))
	class UTextBlock* TimerText;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ExposeOnSpawn = "true"), Category = "Default")
	FTimerInfo TimeInfo;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ExposeOnSpawn = "true"), Category = "Default")
	float WarningTime;
private:
	float InSeconds;
	FTimerHandle TimerHandle;
	FTimerHandle DelayHandle;
};
